package org.example.y24.m10;

import java.util.Scanner;

public class Test5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] l = new boolean[m + 1];
        for (int i = 0; i < l.length;i++) {
            l[i] = false;
        }
        int count = 1;

        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            boolean f = false;
            for (int j = 0; j < k; j++) {
                int t = sc.nextInt();
                if (i == 0) {
                    l[t] = true;
                } else {
                    if (l[t]) {
                        f = true;
                    }
                }
            }
            if (f) {
                count++;
            }
        }
        System.out.println(count);
    }
}
